<template>
  <div class="main-header">
    <div class="left">
      <el-icon size="28px" @click="isFoldhandle">
        <component :is="isFold ? 'Expand' : 'Fold'" />
      </el-icon>
      <div class="bread-crumb"><headerCrumb /></div>
    </div>
    <div class="right">
      <headerInfo />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import headerInfo from './c-cpns/header-info.vue'
import headerCrumb from './c-cpns/header-crumb.vue'

// 内部自定义事件
const emit = defineEmits(['foldChange'])

// 记录折叠的状态
const isFold = ref(false)
function isFoldhandle() {
  isFold.value = !isFold.value

  // 将事件和状态传递给父组件,通过自定义事件 emit 传递给父组件
  emit('foldChange', isFold.value)
}
</script>

<style lang="less" scoped>
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  .left {
    display: flex;
    align-items: center;
    height: 100%;
    .bread-crumb {
      margin-left: 8px;
      user-select: none;
    }
  }
}
</style>
